﻿using LibNiconico.NiconicoApi.Extentions;
using LibNiconico.NiconicoApi.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;


namespace LibNiconico.NiconicoApi.Internal
{
    /// <summary>
    /// ニコニココメント送信結果
    /// </summary>
    public abstract class NicoChatResultComment
    {
        /// <summary>
        /// コメントNo
        /// </summary>
        public int No { get; internal set; }

        /// <summary>
        /// 送信結果ステータス
        /// </summary>
        public NicoChatResultStatus Status { get; internal set; }

        /// <summary>
        /// スレッド番号
        /// </summary>
        public string Thread { get; internal set; }

        /// <summary>
        /// コンストラクタ
        /// </summary>
        protected NicoChatResultComment()
        {
            No = 0;
            Status = new NicoChatResultStatus(NicoChatResultStatusCode.None, -1);
            Thread = "";
        }


        /// <summary>
        /// コメント解析
        /// </summary>
        /// <param name="chatResult"></param>
        /// <param name="message"></param>
        protected static void Parse(NicoChatResultComment chatResult, XElement message)
        {


            chatResult.No = XElementExtention.GetAttributeAsInt(message,"no");

            chatResult.Status = NicoChatResultStatus.Create(XElementExtention.GetAttributeAsInt(message, "status"));

            chatResult.Thread = XElementExtention.GetAttributeAsString(message,"thread");
  

            
        }
    }
}
